package com.hhs.storage.controller;


import com.hhs.storage.bean.*;
import com.hhs.storage.service.BaseLogsService;
import com.hhs.storage.service.FlowService;
import com.hhs.storage.service.ImgService;
import com.hhs.storage.util.SysUtil;
import org.springframework.util.StringUtils;
import org.springframework.web.bind.annotation.RequestMapping;

import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RestController;

import javax.annotation.Resource;
import javax.servlet.http.HttpServletRequest;
import java.util.List;
import java.util.Map;

/**
 * 流程处理
 * @author hhs
 * @since 2022-12-01
 */
@RestController
@RequestMapping("/flow")
public class FlowController {
    @Resource
    private BaseLogsService baseLogsService;
    @Resource
    FlowService flowService;
    //查询在途合同流程
    @RequestMapping(value = "check")
    public Map<String, Object> getAll(InputParam inputParam) {
        baseLogsService.log("流程处理","查询在途流程",null);

//        inputParam.setType(1);//合同
        Map<String, Object> map = flowService.getAll(inputParam);
        return map;
    }

    //合同流程操作
    @RequestMapping(value = "check/opera")
    public Map<String, Object> contractFlowOpera(HttpServletRequest request,InputParam inputParam) {
        baseLogsService.log("流程处理","流程操作",null);

        String curUserId = SysUtil.getLoginUserId(request);
        if(StringUtils.isEmpty(curUserId)){
            return ResponseInfo.error("参数错误");
        }
        inputParam.setCurUserId(curUserId);
        Map<String, Object> map = flowService.flowOpera(inputParam);
        return map;
    }
    //查询全部流程
    @RequestMapping(value = "check/list")
    public Map<String, Object> contractFlowList(HttpServletRequest request,InputParam inputParam) {
        baseLogsService.log("流程处理","查询全部流程",null);

        String curUserId = SysUtil.getLoginUserId(request);
        if(StringUtils.isEmpty(curUserId) || StringUtils.isEmpty(inputParam.getMainId())){
            return ResponseInfo.error("参数错误");
        }
        inputParam.setCurUserId(curUserId);
        List<Flow> list = flowService.getListAndCreater(inputParam);
        return ResponseInfo.success(list);
    }


}

